version: "3"

services:
  percona:
    image: "percona/percona-xtradb-cluster:{{ combined_vars.pxc_version }}"
    container_name: "pxc-node-{{ global_bond_ip | ansible.utils.ip4_hex }}"
    hostname: "pxc-node-{{ global_bond_ip | ansible.utils.ip4_hex }}"
    env_file:
      - ".env.mysql"
    volumes:
      - "/usr/share/zoneinfo/{{ global_timezone }}:/etc/localtime"
      - "{{ combined_vars.pxc_deploy_path }}/cert:/cert:ro"
      - "{{ combined_vars.pxc_deploy_path }}/config/my.cnf:/etc/percona-xtradb-cluster.conf.d/my.cnf:ro"
      - "{{ combined_vars.mysql_data_path }}:/var/lib/mysql"
    network_mode: "host"
    healthcheck:
      test: "/usr/bin/mysqladmin ping -uhealthcheck -phealthcheck || exit 1"
      interval: 20s
      timeout: 1s
      retries: 5
    cap_add:
      - SYS_NICE

  xtrabackup:
    image: "percona/percona-xtrabackup"
    container_name: "pxc-xtrabackup"
    volumes:
      - "/usr/share/zoneinfo/{{ global_timezone }}:/etc/localtime"
      - "{{ combined_vars.mysql_backup_data_path }}:/backup"
      - "{{ combined_vars.mysql_data_path }}:/var/lib/mysql"
      - "{{ combined_vars.pxc_deploy_path }}/config/xtrabackup.cnf:/etc/my.cnf:ro"
      - "{{ combined_vars.pxc_deploy_path }}/cert:/cert:ro"
      - "{{ combined_vars.pxc_deploy_path }}/scripts/xtrabackup.sh:/usr/local/bin/xtrabackup.sh"
    command:
      - tail
      - -f
      - /dev/null
    depends_on:
      - percona
    network_mode: "host"

  adminer:
    image: "adminer"
    container_name: "pxc-adminer"
    restart: "always"
    env_file:
      - ".env.adminer"
    volumes:
      - "/usr/share/zoneinfo/{{ global_timezone }}:/etc/localtime"
    ports:
      - "{{ combined_vars.adminer_port }}:8080"